While basic collections like arrays or slices are limited to storing elements of the same data type, structures (structs) allow us to group disparate types into a single unit. This is essential for Martian exploration, where telemetry involves mixed data like names (string) and coordinates (float64).
1. Semantic Grouping vs. Uniformity
Unlike a slice of floats which only tells you "how many," a struct provides a labeled container. Definition: Whereas collections are of the same type, structures allow you to group disparate things together. This prevents "variable soup" by bundling related data into named objects.
2. Atomicity in Operations
By grouping variables, we achieve atomicity. Functions like func Step(a, b Universe) or func (u Universe) Next(x, y int) bool can manipulate entire environments rather than chasing loose primitives. For one-off tasks, anonymous structures (like in Listing 21.1) provide immediate organization without formal type definitions.